package com.framework.tx.dao.impl;

import com.framework.tx.dao.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

@Repository
public class UserDaoImpl implements UserDao {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Override
    public int updateUserAgeByIdAndAge(Integer id, Integer age) {
        return jdbcTemplate.update("update student set age = ? where id = ?", age, id);
    }

    @Override
    public int updateUserGenderByIdAndGender(Integer id, Integer gender) {
        return jdbcTemplate.update("update student set gender = ? where id = ?", gender, id);
    }

    @Override
    public int updateUserByIdAndAgeAndGender(Integer id, Integer age, Integer gender) {
        return jdbcTemplate.update("update student set age = ?, gender = ? where id = ?", age, gender, id);
    }
}
